import { pages } from '../model/pages.js'
import { tags } from '../model/tags.js'
import {renderPage,renderTags} from './common.js'
window.onload = () => {

    renderPage(pages);
    renderTags(tags)

    let tagBtns = document.querySelectorAll('#tags-box .btn');
    tagBtns.forEach(btn => {
        btn.addEventListener('click', (e) => {
            let tag = e.target.dataset.tag;
            console.log('tag', tag);
            let _pages = [];
            if (tag == '全部') {
                return _pages = pages;
            }
            _pages = pages.filter(item => item.tag.indexOf(tag) > -1);

            renderPage(_pages);
        })

    })
}